<template>
    <div>
        <h1>录入</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">姓名</td>
                    <td><input type="text" v-model="info.Name"></td>
                </tr>
                <tr>
                    <td align="right">手机号</td>
                    <td><input type="text" v-model="info.Phone"></td>
                </tr>
                <tr>
                    <td align="right">积分</td>
                    <td><input type="text"v-model="info.JIfen"></td>
                </tr>
                <tr>
                    <td align="right">余额</td>
                    <td><input type="text" v-model="info.Money"></td>
                </tr>
                <tr>
                    <td align="right"></td>
                    <td><input type="button" value="录入" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive} from 'vue'
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
const router=useRouter();
let info:any=reactive({
  Name: '',
  Phone: '',
  JIfen: '',
  Money: '',
})

const ok=()=>{
    axios({
        url:'/api/HY/Add',
        method:'post',
        data:info
    })
    .then((res)=>{
        console.log(res);
        if(res.data==-1)
    {
        alert("姓名重复");
        return;
    }
    if(res.data>0)
    {
        alert("录入成功");
        return;
    }
    else
    {
        alert("录入失败");
        return;
    }
    })
    .catch((err)=>{
        console.log(err);
        
    })
}
</script>

<style scoped>

</style>